package com.guchenbo.example.dubbo;

import com.guchenbo.example.dubbo.animal.Animal;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.rpc.Protocol;

public class ExtensionLoaderDemo {
    public static void main(String[] args) {
        //        ExtensionLoader<HelloService> extensionLoader2 = ExtensionLoader.getExtensionLoader(HelloService.class);

        ExtensionLoader<Animal> animalExtensionLoader = ExtensionLoader.getExtensionLoader(Animal.class);
        Animal animal = animalExtensionLoader.getAdaptiveExtension();
        System.out.println(animal);

        animal = animalExtensionLoader.getDefaultExtension();
        System.out.println(animal);

        ExtensionLoader<Protocol> extensionLoader = ExtensionLoader.getExtensionLoader(Protocol.class);
        ExtensionLoader<Protocol> extensionLoader2 = ExtensionLoader.getExtensionLoader(Protocol.class);
        assert extensionLoader == extensionLoader2;
        Protocol protocol = extensionLoader.getAdaptiveExtension();
        System.out.println(protocol.getClass());

        protocol = extensionLoader.getExtension("dubbo");
        System.out.println(protocol);
    }
}
